<?php
class Module_Mediate_Suggestion extends Module_BaseModule
{
    use Lib_BaseTraitsModule;
    private static $obj = null;
    private $model = null;
    /**
     * 封闭构造
     */
    public function __construct()
    {
        $this->model = new Model_Mediate_Suggestion();
    } 

    /**
     * Undocumented function
     *
     * @return Module_Mediate_Suggestion
     */
    public static function getInstance()
    {
        if (empty(self::$obj)) {
            self::$obj = new self();
        }
        return self::$obj;
    }
    public function insert($save_data)
    {
        if($save_data['callId'] ){
            $history = Module_Mediate_Suggestion::getInstance()->getItemById($save_data['callId'], false, 'callId');;
            if(empty($history)){
                return $this->model->singleInsert($save_data);
            }else{
                $save_data['id'] = $history['id'];
                unset($save_data['callId']);
                return $this->model->singleUpdate($save_data);
            }
        }
        return $this->model->singleUpdate($save_data);
    }
}
